import { Button } from "antd"
import { useDispatch, useSelector } from "react-redux"
import numStatus from '@/store/NumStatus'

const Index = () => {
  const dispatch = useDispatch<AppDispatch>() // redux7以上需要增加一个AppDispatch类型
  const {num } = useSelector((state: RootState)=>({
    num : state.numberreducer.num
  }))

  // 修改仓库数据
  const add = ()=>{
    dispatch({
      type:'add1'
    })
  }
// 异步方法
  const asyncAdd = ()=>{
    dispatch(numStatus.asyncActions.asyncAdd1)
  }
  return (
    <>
      page1
      <p>{num}</p>
      <Button onClick={add}>增加</Button>
      <Button onClick={asyncAdd}>异步增加</Button>
    </>
  )
}
export default Index